/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sys.screen;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.SwingWorker;
import sys.bean.PermissaoBean;
import sys.bean.UsuarioBean;
import sys.dao.PermissaoDao;
import sys.dao.UsuarioDao;
import sys.utils.Mensagens;
import static sys.utils.Utils.escClose;

/**
 *
 * @author Administrador
 */
public class UICadastroUsuario extends javax.swing.JDialog {

    UsuarioBean usuario;
    List<PermissaoBean> listaPermissoes;

    private final String telaRelatorios = "telaRelatorios";
    private final String telaVendas = "telaVendas";
    private final String telaAnaliseVendas = "telaAnaliseVendas";
    private final String telaValeMercadoria = "telaValeMercadoria";
    private final String telaClientes = "telaClientes";
    private final String telaAnaliseClientes = "telaAnaliseClientes";
    private final String telaTopClientes = "telaTopClientes";
    private final String telaGerarCobranca = "telaGerarCobranca";
    private final String telaDescontoJurosRecebimento = "telaDescontoJurosRecebimento";
    private final String telaClienteXprodutos = "telaClienteXprodutos";
    private final String telaProdutos = "telaProdutos";
    private final String telaSaidaGrupoSubGrupo = "telaSaidaGrupoSubGrupo";
    private final String telaFerramentas = "telaFerramentas";
    private final String telaUtilitarios = "telaUtilitarios";
    private final String telaGerarEtiquetas = "telaGerarEtiquetas";
    private final String telaEntregaFutura = "telaEntregaFutura";
    private final String telaAnalisar = "telaAnalisar";
    private final String telaPedidos = "telaPedidos";
    private final String telaDescontos = "telaDescontos";
    private final String telaReajustes = "telaReajustes";
    private final String telaCaixa = "telaCaixa";
    private final String telaCadastro = "telaCadastro";
    private final String telaUsuarios = "telaUsuarios";
    private final String telaConfiguracoes = "telaConfiguracoes";
    private final String telaParametros = "telaParametros";

    private final String telaSangrias = "telaSangrias";

    /**
     * Creates new form UICadastroUsuario
     *
     * @param parent
     * @param modal
     */
    public UICadastroUsuario(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
        escClose(this);
    }

    public UICadastroUsuario(java.awt.Dialog parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
        escClose(this);
    }

    private void marcaDesmarcaRelatorios(boolean opc) {
        cbVendas.setSelected(opc);
        cbAnaliseDeVendas.setSelected(opc);
        cbValeMercadoria.setSelected(opc);
        cbClientes.setSelected(opc);
        cbAnaliseDeClientes.setSelected(opc);
        cbTopClientes.setSelected(opc);
        cbGerarCobranca.setSelected(opc);
        cbDescontoJurosRecebimento.setSelected(opc);
        cbClienteXprodutos.setSelected(opc);
        cbProdutos.setSelected(opc);
        cbSaidaGrupoSubGrupo.setSelected(opc);
    }

    private void marcaDesmarcaVendas(boolean opc) {
        cbAnaliseDeVendas.setSelected(opc);
        cbValeMercadoria.setSelected(opc);
    }

    private void marcaDesmarcaClientes(boolean opc) {
        cbAnaliseDeClientes.setSelected(opc);
        cbTopClientes.setSelected(opc);
        cbGerarCobranca.setSelected(opc);
        cbDescontoJurosRecebimento.setSelected(opc);
        cbClienteXprodutos.setSelected(opc);
    }

    private void marcaDesmarcaProdutos(boolean opc) {
        cbSaidaGrupoSubGrupo.setSelected(opc);
    }

    private void marcaDesmarcaFerramentas(boolean opc) {
        cbUtilitarios.setSelected(opc);
        cbGerarEtiquetas.setSelected(opc);
        cbEntregaFutura.setSelected(opc);
        cbAnalisar.setSelected(opc);
        cbPedidos.setSelected(opc);
        cbDescontos.setSelected(opc);
        cbReajustes.setSelected(opc);
        cbCaixa.setSelected(opc);
    }

    private void marcaDesmarcaUtilitarios(boolean opc) {
        cbGerarEtiquetas.setSelected(opc);
        cbEntregaFutura.setSelected(opc);
    }

    private void marcaDesmarcaAnalisar(boolean opc) {
        cbPedidos.setSelected(opc);
        cbDescontos.setSelected(opc);
        cbReajustes.setSelected(opc);
        cbCaixa.setSelected(opc);
    }

    private void marcaDesmarcaCadastro(boolean opc) {
        cbUsuarios.setSelected(opc);
    }

    private void marcaDesmarcaConfiguracoes(boolean opc) {
        cbParametros.setSelected(opc);
    }

    private boolean salvar() {
        boolean v = true;
        if (validaCampos()) {

            final BarraProgresso pb = new BarraProgresso(this);
            SwingWorker worker = new SwingWorker() {

                @Override
                protected Object doInBackground() throws Exception {
                    pb.gerarJanela();

                    pb.lbDescricao.setText("CONCEDENDO PERMISSÕES AO USUÁRIO, AGUARDE...");
                    try {
                        UsuarioDao.alterar(retornaObjetoUsuario(), txCodigo.getText());

                        PermissaoDao.excluir(txCodigo.getText());

                        PermissaoDao.incluir(retornaObjetoPermissao());

                    } catch (SQLException ex) {
                        Mensagens.msgErro("erro ao incluir permissões\n" + ex.getMessage());
                    }
                    return null;
                }

                @Override
                protected void done() {
                    pb.fechar();
                }
            };
            worker.execute();

        } else {
            v = false;
        }
        return v;
    }

    private void marcaDesmarcaOpcoes(boolean opc) {
        cbRelatorios.setSelected(opc);
        cbVendas.setSelected(opc);
        cbAnaliseDeVendas.setSelected(opc);
        cbValeMercadoria.setSelected(opc);
        cbClientes.setSelected(opc);
        cbAnaliseDeClientes.setSelected(opc);
        cbTopClientes.setSelected(opc);
        cbGerarCobranca.setSelected(opc);
        cbDescontoJurosRecebimento.setSelected(opc);
        cbClienteXprodutos.setSelected(opc);
        cbProdutos.setSelected(opc);
        cbSaidaGrupoSubGrupo.setSelected(opc);
        cbFerramentas.setSelected(opc);
        cbUtilitarios.setSelected(opc);
        cbGerarEtiquetas.setSelected(opc);
        cbEntregaFutura.setSelected(opc);
        cbAnalisar.setSelected(opc);
        cbPedidos.setSelected(opc);
        cbDescontos.setSelected(opc);
        cbReajustes.setSelected(opc);
        cbCaixa.setSelected(opc);
        cbCadastro.setSelected(opc);
        cbUsuarios.setSelected(opc);
        cbConfiguracoes.setSelected(opc);
        cbParametros.setSelected(opc);

    }

    public void carregaDadosUsuario(String codigo) {
        try {
            usuario = UsuarioDao.getDadosUsuario(codigo);

            txCodigo.setText(usuario.getCodigo());
            if (usuario.getSituacao().equals("ATIVO")) {
                cbAtivo.setSelected(true);
                cbInativo.setSelected(false);
            } else {
                cbAtivo.setSelected(false);
                cbInativo.setSelected(true);
            }
            txNome.setText(usuario.getNome());
            txSenha.setText(usuario.getSenha());
            txConfirmaSenha.setText(usuario.getSenha());
            txFuncao.setText(usuario.getTipo());

        } catch (SQLException ex) {
            Mensagens.msgErro("erro ao carregar dados do usuário\n" + ex.getMessage());
        }
    }

    private boolean validaCampos() {
        boolean v = true;
        String msg = "Verifique:\n";

        if (!txSenha.getText().equals(txConfirmaSenha.getText())) {
            v = false;
            msg += "senhas não conferem;\n";
            txSenha.requestFocus();
        }

        if (txSenha.getText().equals("")) {
            v = false;
            msg += "campo senha não pode ficar vazio;\n";
            txSenha.requestFocus();
        }
        if (!cbAtivo.isSelected() && !cbInativo.isSelected()) {
            v = false;
            msg += "selecione pelo menos uma situação;\n";
        }

        if (v == false) {
            Mensagens.msgErro(msg);
        }

        return v;
    }

    public void carregaPermissoesUsuario(String codigo) {

        try {
            listaPermissoes = PermissaoDao.gerPermissoesUsuario(codigo);

            if (listaPermissoes.size() < 1) {
                //Não esta configurado parâmetros para esse usuário
            } else {
                for (PermissaoBean perm : listaPermissoes) {

                    if (perm.getTela().equals(telaRelatorios)) {
                        if (perm.getPermissao() == 0) {
                            cbRelatorios.setSelected(true);
                        } else {
                            cbRelatorios.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaVendas)) {
                        if (perm.getPermissao() == 0) {
                            cbVendas.setSelected(true);
                        } else {
                            cbVendas.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaAnaliseVendas)) {
                        if (perm.getPermissao() == 0) {
                            cbAnaliseDeVendas.setSelected(true);
                        } else {
                            cbAnaliseDeVendas.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaValeMercadoria)) {
                        if (perm.getPermissao() == 0) {
                            cbValeMercadoria.setSelected(true);
                        } else {
                            cbValeMercadoria.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaClientes)) {
                        if (perm.getPermissao() == 0) {
                            cbClientes.setSelected(true);
                        } else {
                            cbClientes.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaAnaliseClientes)) {
                        if (perm.getPermissao() == 0) {
                            cbAnaliseDeClientes.setSelected(true);
                        } else {
                            cbAnaliseDeClientes.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaTopClientes)) {
                        if (perm.getPermissao() == 0) {
                            cbTopClientes.setSelected(true);
                        } else {
                            cbTopClientes.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaGerarCobranca)) {
                        if (perm.getPermissao() == 0) {
                            cbGerarCobranca.setSelected(true);
                        } else {
                            cbGerarCobranca.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaDescontoJurosRecebimento)) {
                        if (perm.getPermissao() == 0) {
                            cbDescontoJurosRecebimento.setSelected(true);
                        } else {
                            cbDescontoJurosRecebimento.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaClienteXprodutos)) {
                        if (perm.getPermissao() == 0) {
                            cbClienteXprodutos.setSelected(true);
                        } else {
                            cbClienteXprodutos.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaProdutos)) {
                        if (perm.getPermissao() == 0) {
                            cbProdutos.setSelected(true);
                        } else {
                            cbProdutos.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaSaidaGrupoSubGrupo)) {
                        if (perm.getPermissao() == 0) {
                            cbSaidaGrupoSubGrupo.setSelected(true);
                        } else {
                            cbSaidaGrupoSubGrupo.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaFerramentas)) {
                        if (perm.getPermissao() == 0) {
                            cbFerramentas.setSelected(true);
                        } else {
                            cbFerramentas.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaUtilitarios)) {
                        if (perm.getPermissao() == 0) {
                            cbUtilitarios.setSelected(true);
                        } else {
                            cbUtilitarios.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaGerarEtiquetas)) {
                        if (perm.getPermissao() == 0) {
                            cbGerarEtiquetas.setSelected(true);
                        } else {
                            cbGerarEtiquetas.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaEntregaFutura)) {
                        if (perm.getPermissao() == 0) {
                            cbEntregaFutura.setSelected(true);
                        } else {
                            cbEntregaFutura.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaAnalisar)) {
                        if (perm.getPermissao() == 0) {
                            cbAnalisar.setSelected(true);
                        } else {
                            cbAnalisar.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaPedidos)) {
                        if (perm.getPermissao() == 0) {
                            cbPedidos.setSelected(true);
                        } else {
                            cbPedidos.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaDescontos)) {
                        if (perm.getPermissao() == 0) {
                            cbDescontos.setSelected(true);
                        } else {
                            cbDescontos.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaReajustes)) {
                        if (perm.getPermissao() == 0) {
                            cbReajustes.setSelected(true);
                        } else {
                            cbReajustes.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaCaixa)) {
                        if (perm.getPermissao() == 0) {
                            cbCaixa.setSelected(true);
                        } else {
                            cbCaixa.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaCadastro)) {
                        if (perm.getPermissao() == 0) {
                            cbCadastro.setSelected(true);
                        } else {
                            cbCadastro.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaUsuarios)) {
                        if (perm.getPermissao() == 0) {
                            cbUsuarios.setSelected(true);
                        } else {
                            cbUsuarios.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaConfiguracoes)) {
                        if (perm.getPermissao() == 0) {
                            cbConfiguracoes.setSelected(true);
                        } else {
                            cbConfiguracoes.setSelected(false);
                        }
                    }

                    if (perm.getTela().equals(telaParametros)) {
                        if (perm.getPermissao() == 0) {
                            cbParametros.setSelected(true);
                        } else {
                            cbParametros.setSelected(false);
                        }
                    }
                    
                      if (perm.getTela().equals(telaSangrias)) {
                        if (perm.getPermissao() == 0) {
                            cbSangrias.setSelected(true);
                        } else {
                            cbSangrias.setSelected(false);
                        }
                    }
                    

                }
            }

        } catch (SQLException ex) {
            Mensagens.msgErro("erro ao carregar permissoes do usuário\n" + ex.getMessage());
        }

    }

    private UsuarioBean retornaObjetoUsuario() {

        UsuarioBean usuBean = new UsuarioBean();

        usuBean.setNome(txNome.getText());
        usuBean.setSenha(txSenha.getText());
        usuBean.setTipo(txFuncao.getText());

        if (cbAtivo.isSelected()) {
            usuBean.setSituacao("ATIVO");
        } else {
            usuBean.setSituacao("INATIVO");
        }

        return usuBean;
    }

    private List<PermissaoBean> retornaObjetoPermissao() {
        List<PermissaoBean> permissoes = new ArrayList<>();

        if (cbRelatorios.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaRelatorios);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaRelatorios);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbVendas.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaVendas);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaVendas);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbAnaliseDeVendas.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaAnaliseVendas);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaAnaliseVendas);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbValeMercadoria.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaValeMercadoria);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaValeMercadoria);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbClientes.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaClientes);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaClientes);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbAnaliseDeClientes.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaAnaliseClientes);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaAnaliseClientes);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbTopClientes.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaTopClientes);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaTopClientes);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbGerarCobranca.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaGerarCobranca);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaGerarCobranca);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbDescontoJurosRecebimento.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaDescontoJurosRecebimento);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaDescontoJurosRecebimento);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbClienteXprodutos.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaClienteXprodutos);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaClienteXprodutos);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbProdutos.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaProdutos);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaProdutos);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbSaidaGrupoSubGrupo.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaSaidaGrupoSubGrupo);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaSaidaGrupoSubGrupo);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbFerramentas.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaFerramentas);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaFerramentas);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbUtilitarios.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaUtilitarios);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaUtilitarios);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbGerarEtiquetas.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaGerarEtiquetas);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaGerarEtiquetas);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbEntregaFutura.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();
            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaEntregaFutura);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaEntregaFutura);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbAnalisar.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaAnalisar);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaAnalisar);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbPedidos.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaPedidos);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaPedidos);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbDescontos.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaDescontos);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaDescontos);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbReajustes.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaReajustes);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaReajustes);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbCaixa.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaCaixa);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaCaixa);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbCadastro.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaCadastro);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaCadastro);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbUsuarios.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaUsuarios);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaUsuarios);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbConfiguracoes.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaConfiguracoes);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaConfiguracoes);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbParametros.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaParametros);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaParametros);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        if (cbSangrias.isSelected()) {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaSangrias);
            permissao.setPermissao(0);

            permissoes.add(permissao);
        } else {
            PermissaoBean permissao = new PermissaoBean();

            UsuarioBean usuarioBean = new UsuarioBean();
            usuarioBean.setCodigo(txCodigo.getText());
            permissao.setUsuario(usuarioBean);

            permissao.setTela(telaSangrias);
            permissao.setPermissao(1);

            permissoes.add(permissao);
        }

        return permissoes;

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        txConfirmaSenha = new javax.swing.JPasswordField();
        jLabel4 = new javax.swing.JLabel();
        txSenha = new javax.swing.JPasswordField();
        jLabel3 = new javax.swing.JLabel();
        txNome = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txCodigo = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        cbAtivo = new javax.swing.JCheckBox();
        cbInativo = new javax.swing.JCheckBox();
        jLabel5 = new javax.swing.JLabel();
        txFuncao = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        cbRelatorios = new javax.swing.JCheckBox();
        cbVendas = new javax.swing.JCheckBox();
        cbAnaliseDeVendas = new javax.swing.JCheckBox();
        cbValeMercadoria = new javax.swing.JCheckBox();
        cbClientes = new javax.swing.JCheckBox();
        cbAnaliseDeClientes = new javax.swing.JCheckBox();
        cbTopClientes = new javax.swing.JCheckBox();
        cbGerarCobranca = new javax.swing.JCheckBox();
        cbDescontoJurosRecebimento = new javax.swing.JCheckBox();
        cbClienteXprodutos = new javax.swing.JCheckBox();
        cbProdutos = new javax.swing.JCheckBox();
        cbSaidaGrupoSubGrupo = new javax.swing.JCheckBox();
        cbFerramentas = new javax.swing.JCheckBox();
        cbUtilitarios = new javax.swing.JCheckBox();
        cbGerarEtiquetas = new javax.swing.JCheckBox();
        cbEntregaFutura = new javax.swing.JCheckBox();
        cbAnalisar = new javax.swing.JCheckBox();
        cbPedidos = new javax.swing.JCheckBox();
        cbDescontos = new javax.swing.JCheckBox();
        cbCaixa = new javax.swing.JCheckBox();
        cbReajustes = new javax.swing.JCheckBox();
        cbCadastro = new javax.swing.JCheckBox();
        cbUsuarios = new javax.swing.JCheckBox();
        cbTodos = new javax.swing.JCheckBox();
        cbConfiguracoes = new javax.swing.JCheckBox();
        cbParametros = new javax.swing.JCheckBox();
        cbSangrias = new javax.swing.JCheckBox();
        jPanel5 = new javax.swing.JPanel();
        btnSalvar = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("CADASTRO DE USUÁRIOS");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DADOS CADASTRAIS:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 0, 10))); // NOI18N

        txConfirmaSenha.setBackground(new java.awt.Color(245, 245, 245));
        txConfirmaSenha.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txConfirmaSenha.setForeground(new java.awt.Color(51, 51, 255));
        txConfirmaSenha.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txConfirmaSenha.setBorder(null);
        txConfirmaSenha.setPreferredSize(new java.awt.Dimension(0, 15));

        jLabel4.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel4.setText("CONFIRMA SENHA:");

        txSenha.setBackground(new java.awt.Color(245, 245, 245));
        txSenha.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txSenha.setForeground(new java.awt.Color(51, 51, 255));
        txSenha.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txSenha.setBorder(null);
        txSenha.setPreferredSize(new java.awt.Dimension(0, 15));

        jLabel3.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel3.setText("SENHA:");

        txNome.setEditable(false);
        txNome.setBackground(new java.awt.Color(245, 245, 245));
        txNome.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txNome.setForeground(new java.awt.Color(51, 51, 255));
        txNome.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txNome.setBorder(null);
        txNome.setPreferredSize(new java.awt.Dimension(0, 15));

        jLabel2.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel2.setText("NOME:");

        txCodigo.setEditable(false);
        txCodigo.setBackground(new java.awt.Color(245, 245, 245));
        txCodigo.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txCodigo.setForeground(new java.awt.Color(51, 51, 255));
        txCodigo.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txCodigo.setBorder(null);
        txCodigo.setPreferredSize(new java.awt.Dimension(0, 15));

        jLabel1.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel1.setText("CÓDIGO:");

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "SITUAÇÃO:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 0, 10))); // NOI18N

        cbAtivo.setBackground(new java.awt.Color(255, 255, 255));
        cbAtivo.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        cbAtivo.setText("ATIVO");
        cbAtivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAtivoActionPerformed(evt);
            }
        });

        cbInativo.setBackground(new java.awt.Color(255, 255, 255));
        cbInativo.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        cbInativo.setText("INATIVO");
        cbInativo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbInativoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbInativo)
                    .addComponent(cbAtivo))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cbAtivo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(cbInativo)
                .addContainerGap())
        );

        jLabel5.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        jLabel5.setText("FUNÇÃO:");

        txFuncao.setEditable(false);
        txFuncao.setBackground(new java.awt.Color(245, 245, 245));
        txFuncao.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txFuncao.setForeground(new java.awt.Color(51, 51, 255));
        txFuncao.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txFuncao.setBorder(null);
        txFuncao.setPreferredSize(new java.awt.Dimension(0, 15));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(txCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(txNome, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(txSenha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txConfirmaSenha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel5)
                    .addComponent(txFuncao, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txNome, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txCodigo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txFuncao, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txConfirmaSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(90, 90, 90))
        );

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PERMISSÕES:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 0, 10))); // NOI18N

        cbRelatorios.setBackground(new java.awt.Color(255, 255, 255));
        cbRelatorios.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbRelatorios.setText("RELATÓRIOS");
        cbRelatorios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbRelatoriosActionPerformed(evt);
            }
        });

        cbVendas.setBackground(new java.awt.Color(255, 255, 255));
        cbVendas.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbVendas.setText("VENDAS");
        cbVendas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbVendasActionPerformed(evt);
            }
        });

        cbAnaliseDeVendas.setBackground(new java.awt.Color(255, 255, 255));
        cbAnaliseDeVendas.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbAnaliseDeVendas.setText("ANALISE DE VENDAS");
        cbAnaliseDeVendas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAnaliseDeVendasActionPerformed(evt);
            }
        });

        cbValeMercadoria.setBackground(new java.awt.Color(255, 255, 255));
        cbValeMercadoria.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbValeMercadoria.setText("VALE MERCADORIA");
        cbValeMercadoria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbValeMercadoriaActionPerformed(evt);
            }
        });

        cbClientes.setBackground(new java.awt.Color(255, 255, 255));
        cbClientes.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbClientes.setText("CLIENTES");
        cbClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbClientesActionPerformed(evt);
            }
        });

        cbAnaliseDeClientes.setBackground(new java.awt.Color(255, 255, 255));
        cbAnaliseDeClientes.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbAnaliseDeClientes.setText("ANALISE DE CLIENTES");
        cbAnaliseDeClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAnaliseDeClientesActionPerformed(evt);
            }
        });

        cbTopClientes.setBackground(new java.awt.Color(255, 255, 255));
        cbTopClientes.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbTopClientes.setText("TOP CLIENTES");
        cbTopClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTopClientesActionPerformed(evt);
            }
        });

        cbGerarCobranca.setBackground(new java.awt.Color(255, 255, 255));
        cbGerarCobranca.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbGerarCobranca.setText("GERAR COBRANÇA");
        cbGerarCobranca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbGerarCobrancaActionPerformed(evt);
            }
        });

        cbDescontoJurosRecebimento.setBackground(new java.awt.Color(255, 255, 255));
        cbDescontoJurosRecebimento.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbDescontoJurosRecebimento.setText("DESCONTO/JUROS RECEBIMENTO");
        cbDescontoJurosRecebimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbDescontoJurosRecebimentoActionPerformed(evt);
            }
        });

        cbClienteXprodutos.setBackground(new java.awt.Color(255, 255, 255));
        cbClienteXprodutos.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbClienteXprodutos.setText("CLIENTE X PRODUTOS");
        cbClienteXprodutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbClienteXprodutosActionPerformed(evt);
            }
        });

        cbProdutos.setBackground(new java.awt.Color(255, 255, 255));
        cbProdutos.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbProdutos.setText("PRODUTOS");
        cbProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbProdutosActionPerformed(evt);
            }
        });

        cbSaidaGrupoSubGrupo.setBackground(new java.awt.Color(255, 255, 255));
        cbSaidaGrupoSubGrupo.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbSaidaGrupoSubGrupo.setText("SAÍDA POR GRUPO/SUBGRUPO");
        cbSaidaGrupoSubGrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbSaidaGrupoSubGrupoActionPerformed(evt);
            }
        });

        cbFerramentas.setBackground(new java.awt.Color(255, 255, 255));
        cbFerramentas.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbFerramentas.setText("FERRAMENTAS");
        cbFerramentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbFerramentasActionPerformed(evt);
            }
        });

        cbUtilitarios.setBackground(new java.awt.Color(255, 255, 255));
        cbUtilitarios.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbUtilitarios.setText("UTILITÁRIOS");
        cbUtilitarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbUtilitariosActionPerformed(evt);
            }
        });

        cbGerarEtiquetas.setBackground(new java.awt.Color(255, 255, 255));
        cbGerarEtiquetas.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbGerarEtiquetas.setText("GERAR ETIQUETAS");
        cbGerarEtiquetas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbGerarEtiquetasActionPerformed(evt);
            }
        });

        cbEntregaFutura.setBackground(new java.awt.Color(255, 255, 255));
        cbEntregaFutura.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbEntregaFutura.setText("ENTREGA FUTURA");
        cbEntregaFutura.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbEntregaFuturaActionPerformed(evt);
            }
        });

        cbAnalisar.setBackground(new java.awt.Color(255, 255, 255));
        cbAnalisar.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbAnalisar.setText("ANALISAR");
        cbAnalisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAnalisarActionPerformed(evt);
            }
        });

        cbPedidos.setBackground(new java.awt.Color(255, 255, 255));
        cbPedidos.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbPedidos.setText("PEDIDOS");
        cbPedidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbPedidosActionPerformed(evt);
            }
        });

        cbDescontos.setBackground(new java.awt.Color(255, 255, 255));
        cbDescontos.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbDescontos.setText("DESCONTOS");
        cbDescontos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbDescontosActionPerformed(evt);
            }
        });

        cbCaixa.setBackground(new java.awt.Color(255, 255, 255));
        cbCaixa.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbCaixa.setText("CAIXA");
        cbCaixa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbCaixaActionPerformed(evt);
            }
        });

        cbReajustes.setBackground(new java.awt.Color(255, 255, 255));
        cbReajustes.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbReajustes.setText("REAJUSTES");
        cbReajustes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbReajustesActionPerformed(evt);
            }
        });

        cbCadastro.setBackground(new java.awt.Color(255, 255, 255));
        cbCadastro.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbCadastro.setText("CADASTRO");
        cbCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbCadastroActionPerformed(evt);
            }
        });

        cbUsuarios.setBackground(new java.awt.Color(255, 255, 255));
        cbUsuarios.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbUsuarios.setText("USUÁRIOS");
        cbUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbUsuariosActionPerformed(evt);
            }
        });

        cbTodos.setBackground(new java.awt.Color(255, 255, 255));
        cbTodos.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbTodos.setText("MARCAR/DESMARCAR TODOS");
        cbTodos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTodosActionPerformed(evt);
            }
        });

        cbConfiguracoes.setBackground(new java.awt.Color(255, 255, 255));
        cbConfiguracoes.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbConfiguracoes.setText("CONFIGURAÇÕES");
        cbConfiguracoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbConfiguracoesActionPerformed(evt);
            }
        });

        cbParametros.setBackground(new java.awt.Color(255, 255, 255));
        cbParametros.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbParametros.setText("PARÂMETROS");
        cbParametros.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbParametrosActionPerformed(evt);
            }
        });

        cbSangrias.setBackground(new java.awt.Color(255, 255, 255));
        cbSangrias.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
        cbSangrias.setText("SANGRIAS");
        cbSangrias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbSangriasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbRelatorios)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGap(35, 35, 35)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(cbClientes)
                                            .addComponent(cbVendas)
                                            .addComponent(cbProdutos)))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGap(75, 75, 75)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(cbValeMercadoria)
                                            .addComponent(cbAnaliseDeVendas)))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGap(77, 77, 77)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(cbTopClientes)
                                            .addComponent(cbAnaliseDeClientes)
                                            .addComponent(cbGerarCobranca)
                                            .addComponent(cbDescontoJurosRecebimento)
                                            .addComponent(cbSaidaGrupoSubGrupo)
                                            .addComponent(cbClienteXprodutos))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGap(79, 79, 79)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(cbDescontos)
                                            .addComponent(cbPedidos)
                                            .addComponent(cbCaixa)
                                            .addComponent(cbReajustes)
                                            .addComponent(cbSangrias)))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addGap(78, 78, 78)
                                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(cbEntregaFutura)
                                                    .addComponent(cbGerarEtiquetas)))
                                            .addComponent(cbFerramentas)
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addGap(39, 39, 39)
                                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(cbAnalisar)
                                                    .addComponent(cbUtilitarios))))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(cbCadastro)
                                            .addComponent(cbConfiguracoes)
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addGap(39, 39, 39)
                                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(cbUsuarios)
                                                    .addComponent(cbParametros)))))))))
                    .addComponent(cbTodos))
                .addContainerGap(44, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(cbTodos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbRelatorios)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(cbVendas)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbAnaliseDeVendas)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbValeMercadoria)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbClientes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbAnaliseDeClientes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbTopClientes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbGerarCobranca, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbDescontoJurosRecebimento)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbClienteXprodutos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbProdutos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbSaidaGrupoSubGrupo))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(cbFerramentas)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbUtilitarios))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(cbCadastro)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbUsuarios)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(cbGerarEtiquetas)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbEntregaFutura))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(cbConfiguracoes)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbParametros)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbAnalisar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbPedidos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbDescontos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbReajustes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbCaixa)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbSangrias)
                        .addGap(23, 23, 23))))
        );

        jPanel5.setBackground(new java.awt.Color(245, 245, 245));
        jPanel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));

        btnSalvar.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/picture/salvar.png"))); // NOI18N
        btnSalvar.setText("SALVAR");
        btnSalvar.setPreferredSize(new java.awt.Dimension(120, 30));
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });
        jPanel5.add(btnSalvar);

        jButton2.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/picture/sair.png"))); // NOI18N
        jButton2.setText("SAIR");
        jButton2.setPreferredSize(new java.awt.Dimension(120, 30));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 660, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbAtivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAtivoActionPerformed
        cbInativo.setSelected(false);
    }//GEN-LAST:event_cbAtivoActionPerformed

    private void cbInativoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbInativoActionPerformed
        cbAtivo.setSelected(false);
    }//GEN-LAST:event_cbInativoActionPerformed

    private void cbTodosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTodosActionPerformed
        marcaDesmarcaOpcoes(cbTodos.isSelected());
    }//GEN-LAST:event_cbTodosActionPerformed

    private void cbRelatoriosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbRelatoriosActionPerformed
        marcaDesmarcaRelatorios(cbRelatorios.isSelected());
    }//GEN-LAST:event_cbRelatoriosActionPerformed

    private void cbVendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbVendasActionPerformed
        marcaDesmarcaVendas(cbVendas.isSelected());
        if (cbVendas.isSelected()) {
            cbRelatorios.setSelected(true);
        } else {
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbVendasActionPerformed

    private void cbClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbClientesActionPerformed
        marcaDesmarcaClientes(cbClientes.isSelected());
    }//GEN-LAST:event_cbClientesActionPerformed

    private void cbProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbProdutosActionPerformed
        marcaDesmarcaProdutos(cbProdutos.isSelected());
        if (cbProdutos.isSelected()) {
            cbRelatorios.setSelected(true);
        } else {
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbProdutosActionPerformed

    private void cbFerramentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbFerramentasActionPerformed
        marcaDesmarcaFerramentas(cbFerramentas.isSelected());
    }//GEN-LAST:event_cbFerramentasActionPerformed

    private void cbUtilitariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbUtilitariosActionPerformed
        marcaDesmarcaUtilitarios(cbUtilitarios.isSelected());
        cbFerramentas.setSelected(cbUtilitarios.isSelected());
    }//GEN-LAST:event_cbUtilitariosActionPerformed

    private void cbAnalisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAnalisarActionPerformed
        marcaDesmarcaAnalisar(cbAnalisar.isSelected());
    }//GEN-LAST:event_cbAnalisarActionPerformed

    private void cbCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCadastroActionPerformed
        marcaDesmarcaCadastro(cbCadastro.isSelected());
    }//GEN-LAST:event_cbCadastroActionPerformed

    private void cbConfiguracoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbConfiguracoesActionPerformed
        marcaDesmarcaConfiguracoes(cbConfiguracoes.isSelected());
    }//GEN-LAST:event_cbConfiguracoesActionPerformed

    private void cbAnaliseDeVendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAnaliseDeVendasActionPerformed
        if (cbAnaliseDeVendas.isSelected() || cbValeMercadoria.isSelected()) {
            cbVendas.setSelected(true);
            cbRelatorios.setSelected(true);
        } else {
            cbVendas.setSelected(false);
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbAnaliseDeVendasActionPerformed

    private void cbValeMercadoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbValeMercadoriaActionPerformed
        if (cbAnaliseDeVendas.isSelected() || cbValeMercadoria.isSelected()) {
            cbVendas.setSelected(true);
            cbRelatorios.setSelected(true);
        } else {
            cbVendas.setSelected(false);
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbValeMercadoriaActionPerformed

    private void cbAnaliseDeClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAnaliseDeClientesActionPerformed
        if (cbAnaliseDeClientes.isSelected() || cbTopClientes.isSelected() || cbGerarCobranca.isSelected() || cbDescontoJurosRecebimento.isSelected()
                || cbClienteXprodutos.isSelected()) {
            cbClientes.setSelected(true);
            cbRelatorios.setSelected(true);
        } else {
            cbClientes.setSelected(false);
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbAnaliseDeClientesActionPerformed

    private void cbTopClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTopClientesActionPerformed
        if (cbAnaliseDeClientes.isSelected() || cbTopClientes.isSelected() || cbGerarCobranca.isSelected() || cbDescontoJurosRecebimento.isSelected()
                || cbClienteXprodutos.isSelected()) {
            cbClientes.setSelected(true);
            cbRelatorios.setSelected(true);
        } else {
            cbClientes.setSelected(false);
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbTopClientesActionPerformed

    private void cbGerarCobrancaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGerarCobrancaActionPerformed
        if (cbAnaliseDeClientes.isSelected() || cbTopClientes.isSelected() || cbGerarCobranca.isSelected() || cbDescontoJurosRecebimento.isSelected()
                || cbClienteXprodutos.isSelected()) {
            cbClientes.setSelected(true);
            cbRelatorios.setSelected(true);
        } else {
            cbClientes.setSelected(false);
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbGerarCobrancaActionPerformed

    private void cbDescontoJurosRecebimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDescontoJurosRecebimentoActionPerformed
        if (cbAnaliseDeClientes.isSelected() || cbTopClientes.isSelected() || cbGerarCobranca.isSelected() || cbDescontoJurosRecebimento.isSelected()
                || cbClienteXprodutos.isSelected()) {
            cbClientes.setSelected(true);
            cbRelatorios.setSelected(true);
        } else {
            cbClientes.setSelected(false);
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbDescontoJurosRecebimentoActionPerformed

    private void cbClienteXprodutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbClienteXprodutosActionPerformed
        if (cbAnaliseDeClientes.isSelected() || cbTopClientes.isSelected() || cbGerarCobranca.isSelected() || cbDescontoJurosRecebimento.isSelected()
                || cbClienteXprodutos.isSelected()) {
            cbClientes.setSelected(true);
            cbRelatorios.setSelected(true);
        } else {
            cbClientes.setSelected(false);
            cbRelatorios.setSelected(false);
        }
    }//GEN-LAST:event_cbClienteXprodutosActionPerformed

    private void cbSaidaGrupoSubGrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSaidaGrupoSubGrupoActionPerformed
        cbProdutos.setSelected(cbSaidaGrupoSubGrupo.isSelected());
        cbRelatorios.setSelected(cbSaidaGrupoSubGrupo.isSelected());
    }//GEN-LAST:event_cbSaidaGrupoSubGrupoActionPerformed

    private void cbGerarEtiquetasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGerarEtiquetasActionPerformed
        if (cbGerarEtiquetas.isSelected() || cbEntregaFutura.isSelected()) {
            cbUtilitarios.setSelected(true);
            cbFerramentas.setSelected(true);
        } else {
            cbUtilitarios.setSelected(false);
            cbFerramentas.setSelected(false);
        }
    }//GEN-LAST:event_cbGerarEtiquetasActionPerformed

    private void cbEntregaFuturaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEntregaFuturaActionPerformed
        if (cbGerarEtiquetas.isSelected() || cbEntregaFutura.isSelected()) {
            cbUtilitarios.setSelected(true);
            cbFerramentas.setSelected(true);
        } else {
            cbUtilitarios.setSelected(false);
            cbFerramentas.setSelected(false);
        }
    }//GEN-LAST:event_cbEntregaFuturaActionPerformed

    private void cbPedidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPedidosActionPerformed
        if (cbPedidos.isSelected() || cbDescontos.isSelected() || cbReajustes.isSelected() || cbCaixa.isSelected() || cbSangrias.isSelected()) {
            cbAnalisar.setSelected(true);
            cbFerramentas.setSelected(true);
        } else {
            cbAnalisar.setSelected(false);
            cbFerramentas.setSelected(false);
        }
    }//GEN-LAST:event_cbPedidosActionPerformed

    private void cbDescontosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDescontosActionPerformed
        if (cbPedidos.isSelected() || cbDescontos.isSelected() || cbReajustes.isSelected() || cbCaixa.isSelected() || cbSangrias.isSelected()) {
            cbAnalisar.setSelected(true);
            cbFerramentas.setSelected(true);
        } else {
            cbAnalisar.setSelected(false);
            cbFerramentas.setSelected(false);
        }
    }//GEN-LAST:event_cbDescontosActionPerformed

    private void cbReajustesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbReajustesActionPerformed
        if (cbPedidos.isSelected() || cbDescontos.isSelected() || cbReajustes.isSelected() || cbCaixa.isSelected() || cbSangrias.isSelected()) {
            cbAnalisar.setSelected(true);
            cbFerramentas.setSelected(true);
        } else {
            cbAnalisar.setSelected(false);
            cbFerramentas.setSelected(false);
        }
    }//GEN-LAST:event_cbReajustesActionPerformed

    private void cbCaixaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCaixaActionPerformed
        if (cbPedidos.isSelected() || cbDescontos.isSelected() || cbReajustes.isSelected() || cbCaixa.isSelected() || cbSangrias.isSelected()) {
            cbAnalisar.setSelected(true);
            cbFerramentas.setSelected(true);
        } else {
            cbAnalisar.setSelected(false);
            cbFerramentas.setSelected(false);
        }
    }//GEN-LAST:event_cbCaixaActionPerformed

    private void cbUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbUsuariosActionPerformed
        cbCadastro.setSelected(cbUsuarios.isSelected());
    }//GEN-LAST:event_cbUsuariosActionPerformed

    private void cbParametrosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbParametrosActionPerformed
        cbConfiguracoes.setSelected(cbParametros.isSelected());
    }//GEN-LAST:event_cbParametrosActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed

        if (salvar()) {
            dispose();
        }
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void cbSangriasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSangriasActionPerformed
        if (cbPedidos.isSelected() || cbDescontos.isSelected() || cbReajustes.isSelected() || cbCaixa.isSelected() || cbSangrias.isSelected()) {
            cbAnalisar.setSelected(true);
            cbFerramentas.setSelected(true);
        } else {
            cbAnalisar.setSelected(false);
            cbFerramentas.setSelected(false);
        }
    }//GEN-LAST:event_cbSangriasActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSalvar;
    private javax.swing.JCheckBox cbAnalisar;
    private javax.swing.JCheckBox cbAnaliseDeClientes;
    private javax.swing.JCheckBox cbAnaliseDeVendas;
    private javax.swing.JCheckBox cbAtivo;
    private javax.swing.JCheckBox cbCadastro;
    private javax.swing.JCheckBox cbCaixa;
    private javax.swing.JCheckBox cbClienteXprodutos;
    private javax.swing.JCheckBox cbClientes;
    private javax.swing.JCheckBox cbConfiguracoes;
    private javax.swing.JCheckBox cbDescontoJurosRecebimento;
    private javax.swing.JCheckBox cbDescontos;
    private javax.swing.JCheckBox cbEntregaFutura;
    private javax.swing.JCheckBox cbFerramentas;
    private javax.swing.JCheckBox cbGerarCobranca;
    private javax.swing.JCheckBox cbGerarEtiquetas;
    private javax.swing.JCheckBox cbInativo;
    private javax.swing.JCheckBox cbParametros;
    private javax.swing.JCheckBox cbPedidos;
    private javax.swing.JCheckBox cbProdutos;
    private javax.swing.JCheckBox cbReajustes;
    private javax.swing.JCheckBox cbRelatorios;
    private javax.swing.JCheckBox cbSaidaGrupoSubGrupo;
    private javax.swing.JCheckBox cbSangrias;
    private javax.swing.JCheckBox cbTodos;
    private javax.swing.JCheckBox cbTopClientes;
    private javax.swing.JCheckBox cbUsuarios;
    private javax.swing.JCheckBox cbUtilitarios;
    private javax.swing.JCheckBox cbValeMercadoria;
    private javax.swing.JCheckBox cbVendas;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JTextField txCodigo;
    private javax.swing.JPasswordField txConfirmaSenha;
    private javax.swing.JTextField txFuncao;
    private javax.swing.JTextField txNome;
    private javax.swing.JPasswordField txSenha;
    // End of variables declaration//GEN-END:variables

}
